﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using VCN.App.DataTransferObjects;

namespace VCN.App.DataAccessLayer
{
    public class NewsDAO
    {
        public DataTable SellectNewsTop()
        {
            DataTable v_datasource = new DataTable();
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            string driver = (string)settingsReader.GetValue("ConnectionString", typeof(string));
            SqlConnection v_conn = new SqlConnection(driver);
            try
            {
                v_conn.Open();
            }
            catch (Exception exp)
            {
                HttpContext.Current.Response.Write(exp.ToString());                
            }
            SqlCommand sqlcom = new SqlCommand("sp_tblNews_SelectTop10", v_conn);
            sqlcom.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter v_sqladapter = new SqlDataAdapter(sqlcom);
            v_sqladapter.Fill(v_datasource);            
            try
            {
                sqlcom.ExecuteNonQuery();
                v_conn.Close();
            }
            catch (Exception exp)
            {
                v_conn.Close();
                HttpContext.Current.Response.Write(exp.ToString());
            }
            return v_datasource;
        }

    }
}
